<template>
  <el-autocomplete
    class="inline-input"
    v-model="value"
    :debounce="500"
    :trigger-on-focus="false"
    :fetch-suggestions="querySearch"
    placeholder="请输入内容"
    @select="changeValue($event)"
    style="width:100%"
    :disabled= "val1"
  >
    <!-- <template slot-scope="{ item }">
      <div class="name" :title='item.value'><span style="float:left">{{ item.value }}</span><span
        style="float: right ; color: #8492a6; font-size: 12px">&nbsp;&nbsp;1{{ item.unitName }}={{item.convertedQuantity}}{{item.auxiliaryUnitName}}</span>
      </div>
    </template> -->
    <template slot-scope="{ item }">
      <div class="name" :title='item.value'><span style="float:left">{{ item.value }}</span><span
        style="float: right ; color: #8492a6; font-size: 12px"></span>
      </div>
    </template>

  </el-autocomplete>

</template>

<script>
  import request from '@/utils/request'

  export default {
    data() {
      return {
        value: '',
        goodsList: [],
        callbackMethod: '',
        obj: {},
        obj1:{},
        queryString: '',
        params:{}
      }
    },
    props: ["val2","val1"],

    created() {
    },
    mounted() {

    },
    methods: {
      querySearch(queryString, callback) {
        this.params = {
          shipmentCode: this.val2,
          keywords: queryString,
        }
        var list = [{}]
        var that = this
        request({
          url: '/wms/goods/search',
          method: 'get',
          params: this.params
        }).then(response => {
          this.goodsList = response.data
        })
          .then((response) => {
            for (let i of this.goodsList) {
              i.value = i.name
            }
            list = this.goodsList
            callback(list)
          }).catch((error) => {
          console.log(error)
        })
      },
      setSelectValue(value) {
        this.value = value
      },
      changeValue(e) {
        this.obj = e
        this.obj1 = e
        // e.name = e.value
        this.$emit('setGoodsCode', e)

      }
    }
  }
</script>
